package com.jymj.service.impl;

import com.jymj.dao.ZjdLzDao;
import com.jymj.entity.SysUserEntity;
import com.jymj.entity.model.CommonEnumEnty;
import com.jymj.entity.zjd.ZjdCountEntity;
import com.jymj.entity.zjd.ZjdLzEntity;
import com.jymj.service.ZjdLzService;
import com.jymj.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ljj on 2019/10/14.
 */
@Service
public class ZjdLzServiceImpl implements ZjdLzService {
    @Autowired
    private ZjdLzDao zjdLzDao;

    @Override
    public boolean queryFileStatus(int status, List<Integer> zjdFileIds) {
        Map map  = new HashMap();
        map.put("status",status);
        map.put("zjdFileIds",zjdFileIds);
        List<CommonEnumEnty> comEntyList = zjdLzDao.queryFileStatus(map);
        for (CommonEnumEnty  commonEnum:comEntyList) {
            if(commonEnum.getKey() !=110 && (commonEnum.getKey1()==null || commonEnum.getStatus1()==null)){
                return false;
            }
            //驳回资料
            /*if(status==5 && commonEnum.getKey() ==110){
                if(commonEnum.getCount()==null || commonEnum.getCount()<1){
                    return false;
                }
            }*/
        }
        return true;
    }

    @Override
    public void save(ZjdLzEntity zjdLzEntity) {
        zjdLzDao.save(zjdLzEntity);
    }

    @Override
    public List<ZjdLzEntity> queryList(Map<String, Object> params) {
        /*SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        params.put("sysUser",sysUserEntity);*/
        return zjdLzDao.queryList(params);
    }

    @Override
    public int queryTotal(Map<String, Object> params) {
        /*SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        params.put("sysUser",sysUserEntity);*/
        return zjdLzDao.queryTotal(params);
    }

    @Override
    public ZjdLzEntity queryObject(Integer id) {
        return zjdLzDao.queryObject(id);
    }

    @Override
    public List<ZjdLzEntity> queryListById(Integer[] ids) {
        return zjdLzDao.queryListById(ids);
    }

    @Override
    public void deleteBatch(Integer[] ids) {
        zjdLzDao.deleteBatch(ids);
    }

    @Override
    public void update(ZjdLzEntity zjdLzEntity) {
        /*if(zjdLzEntity.getSptype()!=null && zjdLzEntity.getSptype()==5){
            zjdLzEntity.setBhDate(new Date());
        }*/
        zjdLzDao.update(zjdLzEntity);
    }

    @Override
    public void updateYlBatch(Integer[] lzIds, int i) {
        Map map = new HashMap();
        map.put("array",lzIds);
        map.put("sptype",i);
        zjdLzDao.updateYlBatch(map);
    }

    @Override
    public List<ZjdLzEntity> queryTypeCount(String xzqmc, Integer type) {
        Map map  = new HashMap();
        SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
        map.put("sysUser",sysUserEntity);
        map.put("xzqmc",xzqmc);
        map.put("type",type);
        return zjdLzDao.queryTypeCount(map);
    }

    @Override
    public ZjdLzEntity queryObjectByylId(Integer objectid) {
        return zjdLzDao.queryObjectByylId(objectid);
    }

    @Override
    public ZjdCountEntity queryAllCount(String point, String code) {
        return zjdLzDao.queryAllCount(point,code);
    }

    @Override
    public void updateYl(Integer ylId, Integer sptype) {
        zjdLzDao.updateYl(ylId,sptype);
    }


}
